
/*
*Released on 28th June 2008.
*Any violations can be reported at paritosh@wikiocean.net
*What is treated as violations can be found at www.wikiocean.net/ppl1-voilations*
******************************************************************************
* The contents of this file are subject to POOL Public License 1.0 and later.
* POOL Public License is based on Affero GPL v3 and additional conditions.
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the Affero GPL v3 License at http://www.gnu.org/licenses/agpl.html
* You may obtain a copy of the POOL Public License 1.0 or later at www.wikiocean.net/license/ppl.html
* Software distributed under POOL Public License 1.0 is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Initial Developer of the Original Code is Paritosh Pungaliya (C) 2008. All Rights Reserved.
******************************************************************************
* Objective of the additional terms (license)
* 1) Is to extend the software freedom to freedom to work.
* 2) To ensure that knowledge is free from monopoly of agencies.
* 3) To avoid a situation where big corporate or investor can buy out free software groups and companies and then start milking the communities built around it.
* (this trend can be seen how the freedom is curtailed in companies that get Venture Capital funding.)
******************************************************************************
*/

package  display;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Hashtable;

import utility.*;
import java.util.Vector;

import logger.PoolLogger;



import database.RecordSearch;
import dbmanager.Column;
import dbmanager.DBManager;
import dbmanager.GetIdName;
import file.FileUtility;
//import file.SearchRecord;

public class Heading
{
	String id;
	String HEADING="Heading";
	GetIdName gid ;
	//String Basic_path=Input.MASTERREPORTSPATH;
	String path;
	//SearchRecord Sr;
	RecordSearch ps;
	Hashtable<Object, Object> table =new Hashtable<Object, Object>();
	public Vector<Field> Heading_vector= new Vector<Field>();
	PoolLogger pl;
	
	public Heading() {
		// logger
		pl = (PoolLogger) PoolLogger.getLogger(this.getClass().getName());
	}
	
	public Heading(String id)
	{	
		this.id = id;
		gid = new GetIdName();
		HEADING = gid.getId(HEADING);
	//	path = Basic_path.concat(id+"//"+id+"_mid"+".txt");
		table.put("mid", id);
		table.put("pid", HEADING);
		table.put("td", "null");
		/*Sr = new SearchRecord(path);
		Sr.fileOpen();
		String line[] = Sr.getRecordSet(table);
		Sr.fileClose();*/
		
		ps = new RecordSearch();
		ps.setConditionMap(table);
		String line[] = ps.getArrayFromResultSet();
		for(int i=0;i<line.length;i++)
		{
			String splitline[]=line[i].split("\t");
			this.id = splitline[Column.pv_index-1]; 
		}
	//	path = Basic_path.concat(this.id+"//"+this.id+"_mid"+".txt");
	
	}

	public void get_Object()
	{	
		Hashtable<Object,Object> map = new Hashtable<Object,Object>();
		map.put("mid", id);
		map.put("td", "null");
		try {
			//RandomAccessFile file1 = new RandomAccessFile(path,"r");
			//FileUtility Fu =  new FileUtility(file1);
			/*Sr = new SearchRecord(path);
			System.out.println(map);
			String line[] = Sr.getRecordSet(map);*/
			
			ps = new RecordSearch();
			ps.setConditionMap(map);
			String line[] = ps.getArrayFromResultSet();
			//int index_pid =  Fu.getColumnIndex("pid")-1;			
			//int index_pv =   Fu.getColumnIndex("PV")-1;
			int index_pid =  Column.pid_index-1;			
			int index_pv = Column.pv_index-1;   
			for(int i=0;i<line.length;i++)
			{
				String SubString[] = line[i].split("\t");
				if(SubString[index_pid].equals(HEADING))
				{
					Field f = new Field();
					f.setId(SubString[index_pv]);
					f.getObject();
					Heading_vector.add(f);
				}	
			}
			for(int i=0;i<Heading_vector.size();i++)
			{
				System.out.println("The Vector is "+Heading_vector.get(i).Result);
				pl.info("The Vector is "+Heading_vector.get(i).Result);
				pl.debug("The Vector is "+Heading_vector.get(i).Result);
				pl.warn("The Vector is "+Heading_vector.get(i).Result);
				pl.fatal("The Vector is "+Heading_vector.get(i).Result);
				pl.error("The Vector is "+Heading_vector.get(i).Result);
				pl.trace("The Vector is "+Heading_vector.get(i).Result);
			}
			//file1.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public static void main(String[] args) 
	{
		Heading hd = new Heading("7380");
		hd.get_Object();
	}
}